﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DesignPatterns.Singleton
{
    /// <summary>
    /// 饱汉模式
    /// </summary>
    public class lazySingleton
    {
        private lazySingleton() { }
        private static  lazySingleton instance;

        public static lazySingleton GetLazySingleton()
        {
            if(instance == null)
            {
                lock(typeof(lazySingleton))
                {
                    if(instance == null)
                    {
                        instance = new lazySingleton();
                    }
                }
            }
            return instance;
        }

    }
}
